package com.pinyoumei.app.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.pinyoumei.app.R;
import com.pinyoumei.app.bean.ChooseCouponBean;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2021-06-26.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2021-06-26        Administrator             新增Person类
 * 2021-06-26        Administrator             增加sex属性
 */
public class ChooseCouponAdapter extends BaseQuickAdapter<ChooseCouponBean.ResultBean.UsableCouponListBean, BaseViewHolder> {
    public ChooseCouponAdapter(int layoutResId, @Nullable List<ChooseCouponBean.ResultBean.UsableCouponListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper,ChooseCouponBean.ResultBean.UsableCouponListBean item) {
        ImageView rl_bg = helper.getView(R.id.rl_bg);
        LinearLayout ll_1 = helper.getView(R.id.ll_1);
        CheckBox cb_1 = helper.getView(R.id.cb_1);


        if (item.getType().equals("1")){
            //可用
            rl_bg.setImageResource(R.mipmap.ic_coupon_bg_1);
            ll_1.setVisibility(View.GONE);

            if (item.getClick()){
                cb_1.setChecked(true);
            }else{
                cb_1.setChecked(false);
            }

        }else{
            //不可用
            rl_bg.setImageResource(R.mipmap.ic_coupon_bg_2);
            ll_1.setVisibility(View.VISIBLE);

            helper.setText(R.id.tv_disable_reason,"" + item.getDisable_reason());
        }





        helper.setText(R.id.tv_coupon_amount,"¥" + item.getCoupon_amount());

        helper.setText(R.id.tv_order_price,"满" + item.getOrder_price() + "可用");

        helper.setText(R.id.tv_coupon_title, item.getCoupon_title()+"");

        helper.setText(R.id.tv_use_condition, "适用于：" + item.getUse_condition()+"");

        helper.setText(R.id.tv_expire_time, "有效期：" + item.getExpire_time()+"");




    }
}
